﻿using UnityEngine;
using System.Collections;
using System.Diagnostics;
using System;

public class AttributeDemo : MonoBehaviour
{
	void Start()
	{
		HelpAttribute helpAttribute;
		foreach(var attr in typeof(AnyClass).GetCustomAttributes(true))
		{
			helpAttribute = attr as HelpAttribute;
			if (helpAttribute != null)
			{
				UnityEngine.Debug.Log(string.Format("AnyClass Description:{0}:", helpAttribute.Description));
			}
		}
	}
}

//只能适用于Class
[AttributeUsage(AttributeTargets.Class)]
public class HelpAttribute:Attribute
{
	protected string description;
	public HelpAttribute(string description)
	{
		this.description = description;
	}

	public string Description
	{
		get { return this.description; }
	}
}

[Help("this is a do-nothing class")]
public class AnyClass
{

}
